package com.ff.neuropp.service;


import com.ff.neuropp.domain.Resume;
import com.ff.neuropp.repository.ResumeRepository;
import com.ff.neuropp.util.ResultTool;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * 个人履历服务
 */
@Service
public class AppResumeService {

    @Resource
    private ResumeRepository resumeRepository;


    /***
     * 新增
     * @param param
     * @return
     */
    public Map<String,Object> addResume(Resume param){
        Resume out  = resumeRepository.save(param);
        return ResultTool.genSuccessResult(out);
    }

    /**
     * 个人履历信息查询
     * @param userId
     * @return
     */
    public Map<String,Object> resumes(String userId){
        List<Resume>  list = new ArrayList<>();
        list  = resumeRepository.findAllByUserId(userId);
        return ResultTool.genSuccessResult(list);
    }

    /***
     * 更新
     * @param param
     * @return
     */
    public Map<String,Object> updateResume(Resume param){
        Resume out  = resumeRepository.save(param);
        return ResultTool.genSuccessResult(out);
    }


    /***
     * 删除
     * @param param
     * @return
     */
    public Map<String,Object> delResume(Integer param){
        resumeRepository.deleteById(param);
        return ResultTool.genSuccessResult("删除成功");
    }

}
